package cs3343.project.family.UI;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import cs3343.project.family.GameController;
import cs3343.project.family.StatisticsController;

/**
 * The Class GlobalGameStatFrame.
 */
public class GlobalGameStatFrame extends JFrame {

	/** The gc. */
	private GameController gc;
	
	/** The statistics controller. */
	private StatisticsController statisticsController;
	
	/** The content pane. */
	private JPanel contentPane;
	
	/** The lbl totalruntime. */
	private JLabel lblTotalruntime;
	
	/** The lbl totalgametime. */
	private JLabel lblTotalgametime;
	
	/** The lbl fastestwintime. */
	private JLabel lblFastestwintime;
	
	/** The lbl slowestwintime. */
	private JLabel lblSlowestwintime;
	
	/** The lbl maxesteem. */
	private JLabel lblMaxesteem;
	
	/** The lbl minesteem. */
	private JLabel lblMinesteem;

	/**
	 * Create the frame.
	 *
	 * @param gc the gc
	 */
	public GlobalGameStatFrame(GameController gc) {
		this.gc = gc;
		statisticsController = this.gc.getStatisticsController();
		
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 250, 200);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		GridBagLayout gbl_contentPane = new GridBagLayout();
		gbl_contentPane.columnWidths = new int[]{0, 0, 0, 0, 0};
		gbl_contentPane.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
		gbl_contentPane.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		gbl_contentPane.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		contentPane.setLayout(gbl_contentPane);
		
		JLabel lblTotalGamePlaying = new JLabel("Total Game Playing Time");
		GridBagConstraints gbc_lblTotalGamePlaying = new GridBagConstraints();
		gbc_lblTotalGamePlaying.insets = new Insets(0, 0, 5, 5);
		gbc_lblTotalGamePlaying.gridx = 1;
		gbc_lblTotalGamePlaying.gridy = 1;
		contentPane.add(lblTotalGamePlaying, gbc_lblTotalGamePlaying);
		
		lblTotalgametime = new JLabel("totalGameTime");
		GridBagConstraints gbc_lblTotalgametime = new GridBagConstraints();
		gbc_lblTotalgametime.insets = new Insets(0, 0, 5, 0);
		gbc_lblTotalgametime.gridx = 3;
		gbc_lblTotalgametime.gridy = 1;
		contentPane.add(lblTotalgametime, gbc_lblTotalgametime);
		
		JLabel lblTotalNumberOf = new JLabel("Total Number of Game Play");
		GridBagConstraints gbc_lblTotalNumberOf = new GridBagConstraints();
		gbc_lblTotalNumberOf.insets = new Insets(0, 0, 5, 5);
		gbc_lblTotalNumberOf.gridx = 1;
		gbc_lblTotalNumberOf.gridy = 3;
		contentPane.add(lblTotalNumberOf, gbc_lblTotalNumberOf);
		
		lblTotalruntime = new JLabel("totalRunTime");
		GridBagConstraints gbc_lblTotalruntime = new GridBagConstraints();
		gbc_lblTotalruntime.insets = new Insets(0, 0, 5, 0);
		gbc_lblTotalruntime.gridx = 3;
		gbc_lblTotalruntime.gridy = 3;
		contentPane.add(lblTotalruntime, gbc_lblTotalruntime);
		
		JLabel lblFastestWinningTime = new JLabel("Fastest Winning Time");
		GridBagConstraints gbc_lblFastestWinningTime = new GridBagConstraints();
		gbc_lblFastestWinningTime.insets = new Insets(0, 0, 5, 5);
		gbc_lblFastestWinningTime.gridx = 1;
		gbc_lblFastestWinningTime.gridy = 5;
		contentPane.add(lblFastestWinningTime, gbc_lblFastestWinningTime);
		
		lblFastestwintime = new JLabel("fastestWinTime");
		GridBagConstraints gbc_lblFastestwintime = new GridBagConstraints();
		gbc_lblFastestwintime.insets = new Insets(0, 0, 5, 0);
		gbc_lblFastestwintime.gridx = 3;
		gbc_lblFastestwintime.gridy = 5;
		contentPane.add(lblFastestwintime, gbc_lblFastestwintime);
		
		JLabel lblSlowestWinningTime = new JLabel("Slowest Winning Time");
		GridBagConstraints gbc_lblSlowestWinningTime = new GridBagConstraints();
		gbc_lblSlowestWinningTime.insets = new Insets(0, 0, 5, 5);
		gbc_lblSlowestWinningTime.gridx = 1;
		gbc_lblSlowestWinningTime.gridy = 7;
		contentPane.add(lblSlowestWinningTime, gbc_lblSlowestWinningTime);
		
		lblSlowestwintime = new JLabel("slowestWinTime");
		GridBagConstraints gbc_lblSlowestwintime = new GridBagConstraints();
		gbc_lblSlowestwintime.insets = new Insets(0, 0, 5, 0);
		gbc_lblSlowestwintime.gridx = 3;
		gbc_lblSlowestwintime.gridy = 7;
		contentPane.add(lblSlowestwintime, gbc_lblSlowestwintime);
		
		JLabel lblMaximumEsteemGot = new JLabel("Maximum Esteem Got");
		GridBagConstraints gbc_lblMaximumEsteemGot = new GridBagConstraints();
		gbc_lblMaximumEsteemGot.insets = new Insets(0, 0, 5, 5);
		gbc_lblMaximumEsteemGot.gridx = 1;
		gbc_lblMaximumEsteemGot.gridy = 9;
		contentPane.add(lblMaximumEsteemGot, gbc_lblMaximumEsteemGot);
		
		lblMaxesteem = new JLabel("MaxEsteem");
		GridBagConstraints gbc_lblMaxesteem = new GridBagConstraints();
		gbc_lblMaxesteem.insets = new Insets(0, 0, 5, 0);
		gbc_lblMaxesteem.gridx = 3;
		gbc_lblMaxesteem.gridy = 9;
		contentPane.add(lblMaxesteem, gbc_lblMaxesteem);
		
		JLabel lblMinimumEsteemGot = new JLabel("Minimum Esteem Got");
		GridBagConstraints gbc_lblMinimumEsteemGot = new GridBagConstraints();
		gbc_lblMinimumEsteemGot.insets = new Insets(0, 0, 0, 5);
		gbc_lblMinimumEsteemGot.gridx = 1;
		gbc_lblMinimumEsteemGot.gridy = 11;
		contentPane.add(lblMinimumEsteemGot, gbc_lblMinimumEsteemGot);
		
		lblMinesteem = new JLabel("MinEsteem");
		GridBagConstraints gbc_lblMinesteem = new GridBagConstraints();
		gbc_lblMinesteem.gridx = 3;
		gbc_lblMinesteem.gridy = 11;
		contentPane.add(lblMinesteem, gbc_lblMinesteem);
		
		setLabelValue();
		
		gc.getUiController().frameCentering(this);
	}
	
	/**
	 * Sets the label value.
	 */
	private void setLabelValue() {
		statisticsController.loadGlobalGameStat();
		lblTotalgametime.setText(String.valueOf(statisticsController.getTotalGameTime()));
		lblTotalruntime.setText(String.valueOf(statisticsController.getTotalRunTime()));
		lblFastestwintime.setText(String.valueOf(statisticsController.getFastestWinTime()));
		lblSlowestwintime.setText(String.valueOf(statisticsController.getSlowestWinTime()));
		lblMaxesteem.setText(String.valueOf(statisticsController.getMaxEsteem()));
		lblMinesteem.setText(String.valueOf(statisticsController.getMinEsteem()));
	}

}
